package com.shop.model.controller;

import com.shop.model.entity.Classifys;
import com.shop.model.entity.ShopcartTb;
import com.shop.model.entity.Species;
import com.shop.model.service.IClassifysService;
import com.shop.model.service.IShopcartTbService;
import com.shop.model.service.ISpeciesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {
    @Autowired
    private IClassifysService iClassifysService;
    @Autowired
    private ISpeciesService iSpeciesService;
    /**
     * 跳转到主页
     * 叶虽/获取总分类、分类列表名
     * 作者：谢安建/叶虽
     * @return
     */
    @RequestMapping("/index")
    public String toIndex(Model model){
        //查询所有总类名
        List<Classifys> classifysList = iClassifysService.list();
        for (Classifys classifys : classifysList) {
            Integer classifyId = classifys.getClassifyId();
        }
        //查询所有分类名
        List<Species> speciesList = iSpeciesService.list();
        model.addAttribute("speciesList",speciesList );
        model.addAttribute("classify",classifysList);
        return "index";
    }

    /**
     * 跳转到商品详情处理控制器
     * 作者：谢安建
     * @return
     */
    @RequestMapping("/toDetail")
    public String toDetail(){
        return "redirect:/details";
    }
    @RequestMapping("/tologin")
    public String tologin(){
        return "login";
    }
}
